home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 137 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  60 lines

  1. Path: ousrvr3.oulu.fi!kinnunen
  2. From: kinnunen@stekt.oulu.fi (Teijo Kinnunen)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Layers problem
  5. Date: 3 Jan 1996 12:14:17 GMT
  6. Organization: University of Oulu, Department of Electrical Engineering, Finland
  7. Message-ID: <4cdrup$gqj@ousrvr3.oulu.fi>
  8. NNTP-Posting-Host: stekt10.oulu.fi
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=ISO-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14. Hi everyone,
  15.  
  16. I have a bizarre problem with using layers.library, which I haven't yet
  17. been able to solve.
  18.  
  19. I need a temporary (not displayed) bitmap with clipping, so I have to use
  20. layers. Below's a short program that allocates a bitmap, and then creates
  21. a layer on it, and immediately frees everything.
  22.  
  23. --- cut ---
  24. #include <proto/layers.h>
  25. #include <proto/graphics.h>
  26.  
  27. void main(int argc,char **argv)
  28. {
  29.     struct Layer *la;
  30.     struct Layer_Info *li;
  31.     struct BitMap *bmap = AllocBitMap(640,80,1,BMF_CLEAR|BMF_DISPLAYABLE,
  32.         NULL);
  33.     li = NewLayerInfo();
  34.     la = CreateBehindLayer(li,bmap,0,0,639,79,LAYERSMART|LAYERBACKDROP,
  35.         NULL);
  36.     DeleteLayer(0,la);
  37.     DisposeLayerInfo(li);
  38.     FreeBitMap(bmap);
  39. }
  40. --- cut ---
  41. (*Ought to* work under OS 3.0/3.1, compiles with SAS/C V6.56)
  42.  
  43. Anyway, it does not work. The allocation seems to work fine, but the
  44. FreeBitMap() call corrupts memory. (At least if the program is run a
  45. couple of times. Enforcer can be used, but Mungwall causes the bug to
  46. vanish.)
  47.  
  48. Is there anything wrong in the above piece of code, or have I found a
  49. bug in OS 3.1? I'd appreciate if someone who's more clever than me
  50. could shed some light on the matter...
  51.  
  52. - Teijo
  53.  
  54. --
  55.     o------------------------------------------------------------------o
  56.    /  Teijo Kinnunen - Valkkyla 7 as 413 - 90100  OULU - FINLAND      /
  57.   /  Student at University of Oulu, Dept. of Electrical Engineering  /
  58.  /  Teijo.Kinnunen@oulu.fi   --   http://stekt.oulu.fi/~kinnunen/   /
  59. o------------------------------------------------------------------o
  60.